<template>
  <div>
    <nav-bar bgColor="'#'+fffff">
      <div slot="left" class="goback" @click="backClick"></div>
      <div slot="center" class="titles">
        <div
          v-for="(item, key) in titles"
          :key="key"
          class="titles-item"
          :class="{ current: current === key }"
          @click="itemClick(key)"
        >
          {{ item }}
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar";
export default {
  data() {
    return {
      titles: ["商品", "参数", "评论", "推荐"],
      current: 0,
    };
  },
  components: {
    NavBar,
  },
  methods: {
    itemClick(key) {
      this.current = key;
      this.$emit('topTitles', key)
    },
    backClick() {
        this.$router.back()
    }
  },
};
</script>

<style scoped>
.titles {
  display: flex;
  color: var(--color-text);
}
.titles-item {
  flex: 1;
  font-size: 14px;
}
.current {
  color: var(--color-tint);
}
.goback {
  position: absolute;
  top: 13px;
  left: 18px;
  border: 10px solid transparent;
  border-right: 10px solid var(--color-text);
}

.goback:after {
  content: "";
  position: absolute;
  top: -10px;
  left: -7px;
  border: 10px solid transparent;
  border-right: 10px solid #fff;
}
</style>